//
//  DKHomeAuthCongratulationAlertView.m
//  DanKU
//
//  Created by 蓝鳍互娱 on 2023/12/9.
//

#import "DKHomeAuthCongratulationAlertView.h"
#import "DKAuthLeftCongraView.h"
#import "DKAuthRightCongraView.h"
@interface DKHomeAuthCongratulationAlertView()
@property (nonatomic, weak)zhPopupController * dk_AuthCongratulationAlertPop;
@property (copy, nonatomic) void (^finishCompletion)(void);
@property (nonatomic,strong) DKAuthLeftCongraView *dk_AuthLeftCongraView;
@property (nonatomic,strong) DKAuthRightCongraView *dk_AuthRightCongraView;
@end
@implementation DKHomeAuthCongratulationAlertView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.whiteColor;
        self.layer.cornerRadius = 50;
        self.clipsToBounds = YES;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UILabel *dk_CongratulationHeadLab = [[UILabel alloc] init];
    dk_CongratulationHeadLab.textColor = DK_Hex(@"#333333");
    dk_CongratulationHeadLab.font = DK_FONT_Medium(17);
    dk_CongratulationHeadLab.text = @"Congratulations!";
    [self addSubview:dk_CongratulationHeadLab];
    [dk_CongratulationHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(24)));
        make.centerX.equalTo(self);
    }];
    UILabel *dk_CongratulationAlertLab = [[UILabel alloc] init];
    dk_CongratulationAlertLab.textColor = DK_Hex(@"#333333");
    dk_CongratulationAlertLab.font = DK_FONT_Regular(14);
    dk_CongratulationAlertLab.text = @"Your limit will increase!";
    [self addSubview:dk_CongratulationAlertLab];
    [dk_CongratulationAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(dk_CongratulationHeadLab.mas_bottom).offset(DK_IsWidthScale(10));
        make.height.equalTo(@(DK_IsWidthScale(20)));
    }];
    self.dk_AuthLeftCongraView = [[DKAuthLeftCongraView alloc] init];
    [self addSubview:self.dk_AuthLeftCongraView];
    [self.dk_AuthLeftCongraView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(20)));
        make.top.equalTo(@(DK_IsWidthScale(114)));
        make.width.equalTo(@(DK_IsWidthScale(130)));
        make.height.equalTo(@(DK_IsWidthScale(124)));
    }];
    self.dk_AuthRightCongraView = [[DKAuthRightCongraView alloc] init];
    [self addSubview:self.dk_AuthRightCongraView];
    [self.dk_AuthRightCongraView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-DK_IsWidthScale(20)));
        make.top.equalTo(self.dk_AuthLeftCongraView);
        make.width.equalTo(self.dk_AuthLeftCongraView);
        make.height.equalTo(self.dk_AuthLeftCongraView);
    }];
    UIButton * dk_ConfirmBtn = [[UIButton alloc] init];
    [dk_ConfirmBtn setTitle:@"Confirm" forState:UIControlStateNormal];
    [dk_ConfirmBtn setTitleColor:DK_Hex(@"#FFFFFF") forState:UIControlStateNormal];
    dk_ConfirmBtn.titleLabel.font = DK_FONT_Semibold(16);
    [dk_ConfirmBtn setBackgroundImage:DK_GetImage(@"dk_registerNextSelectBg") forState:UIControlStateNormal];
    [dk_ConfirmBtn addTarget:self action:@selector(goConfirm) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:dk_ConfirmBtn];
    [dk_ConfirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.right.equalTo(@(-DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(50)));
        make.top.equalTo(self.dk_AuthRightCongraView.mas_bottom).offset(DK_IsWidthScale(42));
    }];
    UILabel *dk_CongratulationBottomAlertLab = [[UILabel alloc] init];
    dk_CongratulationBottomAlertLab.textColor = DK_Hex(@"#999999");
    dk_CongratulationBottomAlertLab.font = DK_FONT_Regular(10);
    dk_CongratulationBottomAlertLab.text = @"Repaying on time will help increase your credit limit";
    [self addSubview:dk_CongratulationBottomAlertLab];
    [dk_CongratulationBottomAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(dk_ConfirmBtn.mas_bottom).offset(DK_IsWidthScale(10));
        make.height.equalTo(@(DK_IsWidthScale(14)));
    }];
}
- (void)goConfirm{
    if(self.finishCompletion){
        self.finishCompletion();
    }
    [self.dk_AuthCongratulationAlertPop dismiss];
}
+ (void)dk_ShowAuthCongratulationAlertViewComplete:(void(^)(void))complete{
    DKHomeAuthCongratulationAlertView * dk_AuthCongratulationAlertView = [[DKHomeAuthCongratulationAlertView alloc] init];
    zhPopupController * sureAuthStartCtrl = [[zhPopupController alloc] initWithView:dk_AuthCongratulationAlertView size:CGSizeMake(DK_SCREEN_W-DK_IsWidthScale(60), DK_IsWidthScale(390))];
    dk_AuthCongratulationAlertView.finishCompletion = complete;
    sureAuthStartCtrl.presentationStyle = zhPopupSlideStyleTransform;
    sureAuthStartCtrl.layoutType = zhPopupLayoutTypeCenter;
    sureAuthStartCtrl.presentationTransformScale = 0.56;
    sureAuthStartCtrl.dismissonTransformScale = 0.56;
    sureAuthStartCtrl.dismissOnMaskTouched = NO;
    dk_AuthCongratulationAlertView.dk_AuthCongratulationAlertPop = sureAuthStartCtrl;
    [sureAuthStartCtrl showInView:((AppDelegate*)([UIApplication sharedApplication].delegate)).window completion:^{
    }];
}
@end
